package com.reader.api.pay.processors;

import com.reader.api.constants.PayPlatformTypeEnum;
import com.reader.api.pay.request.PayCallbackRequest;
import com.reader.api.pay.request.PayRequest;
import com.reader.api.pay.response.PayCallbackResponse;
import com.reader.api.pay.response.PayResponse;

import javax.annotation.PostConstruct;

/**
 * 抽象pay处理器.
 *
 * @author liujianqing
 * @date 2018/10/25
 */
public abstract class AbstractPayProcessor {
    /**
     * 平台信息.
     *
     * @return
     */
    public abstract PayPlatformTypeEnum getPayPlatformTypeEnum();


    /**
     * 订单提交到支付平台.
     *
     * @param request
     * @return
     */
    public abstract PayResponse payCommit(PayRequest request);


    /**
     * 处理支付回调.
     *
     * @param payCallbackRequest
     * @return
     */
    public abstract PayCallbackResponse payCallback(PayCallbackRequest payCallbackRequest);

    @PostConstruct
    protected void init() {
        PayProcessorContent.registProcessor(getPayPlatformTypeEnum(), this);
    }
}
